<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>设置</el-breadcrumb-item>
      <el-breadcrumb-item>个人信息</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="add_app">
      <el-form label-width="80px">
        <el-form-item label="选择头像">
          <div class="add_app_addimg">
            <el-upload
              class="avatar-uploader"
              action="https://jsonplaceholder.typicode.com/posts/"
              :show-file-list="false"
              :on-success="handleAvatarSuccess"
              :before-upload="beforeAvatarUpload">
              <img v-if="imageUrl" :src="imageUrl" class="avatar">
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
            </el-upload>
          </div>

        </el-form-item>

      </el-form>
      <el-form label-width="80px">
        <el-form-item label="姓名">
          <el-input></el-input>
        </el-form-item>
      </el-form>
      <el-form label-width="80px">
        <el-form-item label="邮箱">
          <el-input
            placeholder="不可修改"
            v-model="input"
            :disabled="true">
          </el-input>
        </el-form-item>
      </el-form>
      <el-form label-width="80px">
        <el-form-item label="bundle id">
          <el-input></el-input>
        </el-form-item>
      </el-form>
      <el-form label-width="80px">
        <el-form-item label="QQ">
          <el-input></el-input>
        </el-form-item>
      </el-form>
      <el-form label-width="80px">
        <el-form-item label="微信">
          <el-input></el-input>
        </el-form-item>
      </el-form>
      <el-form label-width="80px">
        <el-form-item label="电话">
          <el-input></el-input>
        </el-form-item>
      </el-form>
      <el-form label-width="80px">
        <el-form-item label="">
          <el-button type="primary" @click="submitForm_app">保存</el-button>
        </el-form-item>
      </el-form>

    </div>
  </div>
</template>

<script>
  export default {
    name: "personalInformation",
    data() {
      return {
        imageUrl: '',
        input: ''
      };
    },

    methods: {
      submitForm_app() {
        this.$router.push("/")
        // alert(1111)
      },
      handleAvatarSuccess(res, file) {
        this.imageUrl = URL.createObjectURL(file.raw);
      },
      beforeAvatarUpload(file) {
        const isJPG = file.type === 'image/jpeg';
        const isLt2M = file.size / 1024 / 1024 < 2;
        console.log(file)
        if (!isJPG) {
          this.$message.error('上传头像图片只能是 JPG 格式!');
        }
        if (!isLt2M) {
          this.$message.error('上传头像图片大小不能超过 2MB!');
        }
        return isJPG && isLt2M;
      }
    }
  }
</script>

<style scoped>
  .add_app {
    height: 450px;
    width: 300px;
    /*background-color: #D9D9D9;*/
    margin: 20px auto;
  }

  .avatar-uploader .el-upload {
    border: 1px dashed red;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    background-color: #409EFF;
  }

  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }

  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 100px;
    height: 100px;
    line-height: 100px;
    text-align: center;
  }

  .avatar {
    width: 80px;
    height: 80px;
    display: block;
  }

  .add_app_addimg {
    width: 100px;
    height: 100px;
    border: 1px dashed #d9d9d9;
  }
</style>
